package nl.myhealth.app.myhealthapp.Measurement;

import android.util.Log;

import org.json.JSONObject;

import java.util.Date;

/**
 * Created by Stephan E G Veenstra on 28-9-2014.
 */
public class PulseMeasurement extends Measurement {

    private int pulse;

    public PulseMeasurement(Date timestamp, int pulse)
    {
        super(timestamp);
        setPulse(pulse);
    }

    public PulseMeasurement(){}

    public PulseMeasurement(String json)
    {
        try {
            JSONObject m = new JSONObject(json);
            Log.w("PULSEMEASUREMENT parsed",m.getString("timestamp"));
            setPulse(m.getInt("pulse"));
            setTimestamp(m.getString("timestamp"));

        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void setPulse(int pulse) {
        this.pulse = pulse;
    }

    public int getPulse()
    {
        return this.pulse;
    }

    @Override
    public String toJsonString()
    {
        return "{\"timestamp\":\"" + getTimestampString() + "\", \"pulse\":" + getPulse() + "}";
    }
}
